﻿using Ionic.Zip;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UpdateUDMBackService
{
    public class ZipUtil
    {
        //private static LogUtil log = new LogUtil("BoschExcelAddin.Utils.ZipUtil");

        #region 解压
        /// <summary>
        /// 解压功能(解压压缩文件到指定目录)
        /// </summary>
        /// <param name="fileToUnZip">待解压的文件</param>
        /// <param name="zipedFolder">指定解压目标目录</param>
        /// <returns>解压结果</returns>
        public static bool UnZip(string fileToUnZip, string zipedFolder)
        {
            try
            {
                using (ZipFile zip = new ZipFile(fileToUnZip))
                {
                    zip.ExtractAll(zipedFolder, ExtractExistingFileAction.OverwriteSilently);
                }
                return true;
            }
            catch (Exception ex)
            {
                //log.Error("UnZip:", ex);
                //CommonUtil.ShowWPFMessage("UnZip", ex);
                return false;
            }
        }

        #endregion
    }
}
